package com.atkxp.sys.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.CellData;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.google.common.collect.ImmutableMap;
import org.apache.poi.ss.formula.functions.T;

import java.util.Map;

/**
 * @author longhunpomie
 * @declaration
 * @email 3314028177@qq.com
 * @create 2023/10/12-17:04
 */
public class OperatorTypeConverter implements Converter<Integer> {
    public static final Map<Integer,String> DEMO_TYPE_MAP = ImmutableMap.<Integer,String>builder()
            .put(Integer.valueOf("0"),"其他")
            .put(Integer.valueOf("1"),"后台用户")
            .put(Integer.valueOf("2"),"手机用户")
            .build();
    @Override
    public Class<?> supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return new WriteCellData<>(DEMO_TYPE_MAP.getOrDefault(value,""));
    }
}
